// 考虑用户未登录情况，统一实现接口拦截处理鉴权校验
module.exports = ({white})=>{
    return async (ctx,next)=>{
        if(white.includes(ctx.url)){
            await next();
        }else{
            try {
                //获取请求头里的token
                const {token} = ctx.header||null;
                //解析token
                const userInfo = await ctx.helper.token.verify(token);
                await next()
            } catch (err) {
                ctx.body = {
                    code:402,
                    msg:'token效验失败'
                }
            }
        }
    }
}